<< Índice
Introducción a la optimización por enjambre de partículas¶
La optimización por enjambre de partículas, también conocida como PSO por sus siglas en inglés (Particle Swarm Otimization) es un método de optimización basada en la imitación del comportamiento de las bandadas de pájaros y los bancos de peces. Como lo dicen sus creadores, Kennedy & Eberhart, es un método que busca la optimización de funciones no lienales continuas (1995, p.1). Con esto, podemos inferir que las funciones a optimizar no tienen que ser diferenciables necesariamente, de esta forma abarcando un rango muy amplio de funciones.
2024-03-12 13:35:35,136 - pyswarms.single.global_best - INFO - Optimize for 200 iters with {'c1': 0.5, 'c2': 0.3, 'w': 0.9}
pyswarms.single.global_best: 100%|██████████|200/200, best_cost=6.08e-8
2024-03-12 13:35:35,225 - pyswarms.single.global_best - INFO - Optimization finished | best cost: 6.082745316759261e-08, best pos: [1.00022939 1.00044977]
2024-03-12 13:36:22,010 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 13:36:22,042 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 13:36:22,074 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 13:36:22,162 - py.warnings - WARNING - /var/folders/6g/tjnfv5wj64v0x52560_65xvcsz_6nv/T/ipykernel_32910/3996698340.py:26: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
images.append(imageio.imread('media'+'/'+f'generation_{group}.png'))
Ahora haremos el mismo ejercicio pero con la función en 3 dimensiones
2024-03-12 14:25:44,356 - pyswarms.single.global_best - INFO - Optimize for 250 iters with {'c1': 0.5, 'c2': 0.3, 'w': 0.9}
pyswarms.single.global_best: 100%|██████████|250/250, best_cost=0.0176
2024-03-12 14:25:44,527 - pyswarms.single.global_best - INFO - Optimization finished | best cost: 0.017612407980714378, best pos: [0.96873371 0.94569186 0.89580832]
Graficaremos las curvas de nivel de la función con respecto X1,X3
2024-03-12 14:25:50,363 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:25:50,423 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:25:50,457 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:25:50,569 - py.warnings - WARNING - /var/folders/6g/tjnfv5wj64v0x52560_65xvcsz_6nv/T/ipykernel_32910/2317913914.py:26: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
images.append(imageio.imread('media'+'/'+f'generation_{group}.png'))
Graficaremos las curvas de nivel de la función con respecto X2,X3
2024-03-12 14:26:52,440 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:26:52,519 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:26:52,550 - matplotlib.mathtext - INFO - Substituting symbol R from STIXGeneral
2024-03-12 14:26:52,690 - py.warnings - WARNING - /var/folders/6g/tjnfv5wj64v0x52560_65xvcsz_6nv/T/ipykernel_32910/4241587697.py:26: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
images.append(imageio.imread('media'+'/'+f'generation_{group}.png'))
Ahora puedes volver al índice y seguir explorando el contenido:
<< Índice